package com.cy.model;

import java.util.Date;
import java.util.List;

import com.cy.BasicModel;
import com.cy.ext.plugin.tablebind.TableBind;

@SuppressWarnings("serial")
@TableBind(tableName = "activity_content", pkName = "activity_id")
public class ActivityContent extends BasicModel<ActivityContent> {
	public static final ActivityContent dao = new ActivityContent();
	public static final String SELECT_ALL = "`activity_id`, `activity_name`, `parent_id`, `activity_address`, `activity_date_start`, `activity_date_end`, `activity_code`, `status`, `remark`";
	
	/**
	 * 
	 * @Title: ActivityContent
	 * @Description: 获取根选项
	 * @param: @return
	 * @return: List<ActivityContent>
	 * @throws
	 */
	public List<ActivityContent> getRootItems(){
		return this.find("SELECT" + SELECT_ALL + " from activity_content where parent_id = 0");
	}
	
	/**
	 * 
	 * @Title: ActivityContent
	 * @Description: 获取子选项
	 * @param: @return
	 * @return: List<ActivityContent>
	 * @throws
	 */
	public List<ActivityContent> getChildren(){
		return this.find("SELECT" + SELECT_ALL + " from activity_content where parent_id=?", this.getActivityId());
	}
	
	public void delete(Integer id){
		try {
			List<ActivityContent> list = this.find("select activity_id from activity_content where parent_id = ?", id);
			for(ActivityContent content : list){
				this.deleteById(content.getActivityId());
			}
			this.deleteById(id);
		} catch (Exception e) {
			throw new RuntimeException(e.getMessage());
		}
	}

	public ActivityContent setActivityId(Integer activityId) {
		this.set("activity_id", activityId);
		return this;
	}

	public Integer getActivityId() {
		return this.get("activity_id");
	}

	public ActivityContent setActivityName(String activityName) {
		this.set("activity_name", activityName);
		return this;
	}

	public String getActivityName() {
		return this.get("activity_name");
	}

	public ActivityContent setParentId(Integer parentId) {
		this.set("parent_id", parentId);
		return this;
	}

	public Integer getParentId() {
		return this.get("parent_id");
	}

	public ActivityContent setActivityAddress(String activityAddress) {
		this.set("activity_address", activityAddress);
		return this;
	}

	public String getActivityAddress() {
		return this.get("activity_address");
	}

	public ActivityContent setActivityDateStart(Date dateStart) {
		this.set("activity_date_start", dateStart);
		return this;
	}

	public Date getActivityDateStart() {
		return this.get("activity_date_start");
	}

	public ActivityContent setActivityDateEnd(Date dateEnd) {
		this.set("activity_date_end", dateEnd);
		return this;
	}

	public Date getActivityDateEnd() {
		return this.get("activity_date_end");
	}

	public ActivityContent setActivityCode(Integer activityCode) {
		this.set("activity_code", activityCode);
		return this;
	}

	public Integer getActivityCode() {
		return this.get("activity_code");
	}

	public ActivityContent setStatus(Integer status) {
		this.set("status", status);
		return this;
	}

	public Integer getStatus() {
		return this.get("status");
	}

	public ActivityContent setRemark(String remark) {
		this.set("remark", remark);
		return this;
	}

	public String getRemark() {
		return this.get("remark");
	}

	public ActivityContent setCreateTime(Date createTime) {
		this.set("create_time", createTime);
		return this;
	}

	public Date getCreateTime() {
		return this.get("create_time");
	}

	public ActivityContent setCreateUser(Integer createUser) {
		this.set("create_user", createUser);
		return this;
	}

	public Integer getCreateUser() {
		return this.get("create_user");
	}

	public ActivityContent setUpdateTime(Date updateTime) {
		this.set("update_time", updateTime);
		return this;
	}

	public Date getUpdateTime() {
		return this.get("update_time");
	}

	public ActivityContent setUpdateUser(Integer updateUser) {
		this.set("update_user", updateUser);
		return this;
	}

	public Integer getUpdateUser() {
		return this.get("update_user");
	}
}
